<!DOCTYPE html>
<html lang="en" ng-app="app">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/1.4.8/angular.js"></script>
</head>
<body>
<div ng-controller="myCtrl">
    <div>
        <input type="text" ng-model="value">
    </div>
    <button ng-click="setValue()">设置</button>
    <button ng-click="getValue()">获取</button>
    <button ng-click="deleteValue()">删除</button>
    <br>
    <span>{{result}}</span>
</div>
<script type="application/javascript">
    var app = angular.module("app", []);

    app.service("$cache",function ($cacheFactory) {
        return $cacheFactory("");
    });

    app.controller("myCtrl", ["$scope", "$cache", function ($scope, $cache) {
        $scope.result = "";
        $scope.value = "";
        var cache = $cache;
        $scope.setValue = function () {
            cache.put("test",$scope.value);
        };
        $scope.getValue = function () {
            $scope.result = cache.get("test");
        };
        $scope.deleteValue = function () {
            cache.remove("test");
        };
    }]);
</script>
</body>
</html>